Component({
    properties: {

    },
    data: {
        defaultOptions: {
            size: '1024x1024',
            quality: 'standard',
            style: 'natural'
        },
        options: {}
    },
    lifetimes: {
        attached() {
            this.setData({
                options: JSON.parse(JSON.stringify(this.data.defaultOptions))
            })
        }
    },
    methods: {
        onRadioChange(e) {
            console.log('e', e)
            let name = e.detail.name
            let value = e.detail.value
            let options = this.data.options
            options[name] = value
            this.setData({
                options: options
            })
        },
        getDrawOptions() {
            const options = JSON.parse(JSON.stringify(this.data.options))
            options.words = this.selectComponent('#prompt').getWordsPicked()
            return options
        },
        clearDrawOptions() {
            this.selectComponent('#prompt').clearPicked()
        },
        setDrawOptions(options) {
            options = Object.assign(this.data.defaultOptions, options)
            this.setData({
                options: JSON.parse(JSON.stringify(options))
            })
            if (options.words) {
                this.selectComponent('#prompt').setWords({detail: options.words})
            }
        }
    }
})